--setup
drop SEQUENCE my_sequence_1233492;
drop table source_1233492;
drop table target_1233492;
reset behavior_compat_options;
--step1
CREATE SEQUENCE my_sequence_1233492 START WITH 1 INCREMENT BY 1;
CREATE TABLE source_1233492 (
id NUMBER PRIMARY KEY,
name VARCHAR2(50),
age NUMBER,
height FLOAT
);
INSERT INTO source_1233492 (id, name, age, height) VALUES (my_sequence_1233492.NEXTVAL, 'Alice', 30, 170.5);
INSERT INTO source_1233492 (id, name, age, height) VALUES (my_sequence_1233492.NEXTVAL, 'Bob', 35, 180.2);
INSERT INTO source_1233492 (id, name, age, height) VALUES (my_sequence_1233492.NEXTVAL, 'Charlie', 25, 165.8);

CREATE TABLE target_1233492 (
id NUMBER PRIMARY KEY,
name VARCHAR2(50),
age NUMBER,
height FLOAT
);

--1.INSERT INTO target_1233492 values(data.id,data.height);
declare
cursor cur is
select * from source_1233492;
begin
for data in cur loop
INSERT INTO target_1233492(id, height) values(data.id,data.height);
end loop;
end;
/

select * from target_1233492 order by id;
--2.INSERT INTO target_1233492 values data;
declare
cursor cur is
select id,height from source_1233492;
begin
for data in cur loop
INSERT INTO target_1233492 values data;
end loop;
end;
/

--3.insert into target_1233492 values cur;
declare
begin
for cur in (select id,height from source_1233492) loop
insert into target_1233492 values cur;
commit;
end loop;
end;
/

--设置参数
set behavior_compat_options = 'allow_procedure_compile_check';
delete from target_1233492;
--1.INSERT INTO target_1233492 values data;
declare
cursor cur is
select id,height from source_1233492;
begin
for data in cur loop
INSERT INTO target_1233492(id, height) values data;
end loop;
end;
/

select * from target_1233492 order by id;
delete from target_1233492;

--2.insert into target_1233492 values cur;
declare
begin
for cur in (select id,height from source_1233492) loop
insert into target_1233492(id, height) values cur;
end loop;
end;
/

select * from target_1233492 order by id;
--step2:环境清理
drop SEQUENCE my_sequence_1233492;
drop table source_1233492;
drop table target_1233492;
reset behavior_compat_options;
